const puppeteer = require('puppeteer');

puppeteer.launch().then(async browser => {
    const page = await browser.newPage();
    page.on('request', (req) => {
        if (req.url.startsWith('http://www.dianping.com/ajax/json/shopDynamic/allReview')) {
            console.log('request event' + req.url);
        }
    });
    page.on('response', async (res) => {
        if (res.ok) {
            var req = res.request();
            if (req.url.startsWith('http://www.dianping.com/ajax/json/shopDynamic/allReview')) {
                let data = await res.json();
                console.log(data);
            }
        }
    });
    await page.goto('http://www.dianping.com/shop/91009319');
    const comment = await page.$('#comment');
    //console.log(comment);
    await browser.close();
});